from datetime import datetime


def check_coupon(entered_code, correct_code, current_date, expiration_date):
    """
    优惠券兑换
    电商喜欢在特殊节日发放优惠券。一些客户试图通过输入无效的代码或使用过期的优惠券来欺骗系统
    您的任务:编写一个名为checkCoupon的函数来验证优惠券代码是否有效
    测试用例：
    check_coupon('123','123','September 5, 2014','October 1, 2014')  => True
    check_coupon('123a','123','September 5, 2014','October 1, 2014')  => False
    check_coupon("123", "123", "July 9, 2015", "July 2, 2015")  => False

    :param entered_code: 用户输入的优惠券代码
    :param correct_code: 正确的优惠券代码
    :param current_date: 当前日期，格式为 "Month DD, YYYY"
    :param expiration_date: 优惠券的过期日期，格式为 "Month DD, YYYY"

    :return:如果优惠券有效返回 True，否则返回 False
    """
    # 检查优惠券代码是否正确
    if entered_code != correct_code:
        return False

    # 解析日期
    current_date = datetime.strptime(current_date, "%B %d, %Y")
    expiration_date = datetime.strptime(expiration_date, "%B %d, %Y")

    # 检查优惠券是否在有效期内
    if current_date > expiration_date:
        return False

    return True


if __name__ == '__main__':
    print(check_coupon('123', '123', 'September 5, 2014', 'October 1, 2014'))
    print(check_coupon('123a', '123', 'September 5, 2014', 'October 1, 2014'))
    print(check_coupon("123", "123", "July 9, 2015", "July 2, 2015"))
